﻿<UserControl x:Class="Sautom.Modules.Client.Views.ClientIndex"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
             xmlns:res="clr-namespace:Sautom.I18N;assembly=Sautom.I18N" 
             xmlns:l="clr-namespace:Sautom.ClientComunication.Converters;assembly=Sautom.ClientComunication" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Style TargetType="TextBox">
            <Setter Property="Width" Value="100" />
            <Setter Property="Height" Value="20" />
            <Setter Property="Margin" Value="10,5,0,0" />
        </Style>
        <Style TargetType="Label">
            <Setter Property="Margin" Value="10,5,0,0" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="40" />
            <RowDefinition Height="250*" />
        </Grid.RowDefinitions>
        <Menu Grid.Row="0">
            <MenuItem Header="{Binding Source={x:Static res:ClientResources.ClientDetailsBtn}}" 
                      Command="{Binding ClientDetailsCommand}" />
            <MenuItem Header="{Binding Source={x:Static res:ClientResources.AddNewClientBtn}}" 
                      Command="{Binding AddClientCommand}" />
        </Menu>
        <WrapPanel Orientation="Horizontal" Grid.Row="1" Margin="10,0,0,0">
            <Label Content="{Binding Source={x:Static res:ClientResources.PersonalNumberFilterLabel}}" />
            <TextBox Text="{Binding PersonalNumberFilter}" />
            <Label Content="{Binding Source={x:Static res:ClientResources.NameRuFilterLabel}}" />
            <TextBox Text="{Binding NameRuFilter}" />
            <Label Content="{Binding Source={x:Static res:ClientResources.CourseNameFilterLabel}}" />
            <TextBox Text="{Binding CourseNameFilter}" />
        </WrapPanel>
        <DataGrid Grid.Row="2" ItemsSource="{Binding Clients}" SelectionMode="Single" IsReadOnly="True" 
                  SelectionUnit="FullRow" SelectedItem="{Binding SelectedItem}" CanUserReorderColumns="False" 
                  CanUserResizeColumns="False" CanUserResizeRows="False" CanUserSortColumns="True" 
                  AlternatingRowBackground="Gainsboro"  AlternationCount="2" AutoGenerateColumns="False">    	
            <DataGrid.Columns>
                <DataGridTextColumn Header="{Binding Source={x:Static res:ClientResources.PersonalNumberLabel}}" Binding="{Binding Path=PersonalNumber}" />
                <DataGridTextColumn Header="{Binding Source={x:Static res:ClientResources.NameEnLabel}}" Binding="{Binding Path=NameLat}" />
                <DataGridTextColumn Header="{Binding Source={x:Static res:ClientResources.NameRuLabel}}" Binding="{Binding Path=NameRu}" />
                <DataGridTextColumn Header="{Binding Source={x:Static res:ClientResources.OrdersCountLabel}}" Binding="{Binding Path=OrdersCount}" />

                <DataGridTextColumn Header="{Binding Source={x:Static res:ProposalResources.SchoolNameLabel}}" Binding="{Binding Path=SchoolName}" />
                <DataGridTextColumn Header="{Binding Source={x:Static res:ProposalResources.CourseNameLabel}}" Binding="{Binding Path=CourseName}" />
                <DataGridTextColumn Header="{Binding Source={x:Static res:ProposalResources.StartDateLabel}}" 
                                    Binding="{Binding Path=StartDate, StringFormat= d}" />
            </DataGrid.Columns>
            <!--<DataGrid.RowStyle>
                <Style TargetType="DataGridRow">
                    <Setter Property="Background" Value="{Binding IsHot, Converter={StaticResource IsHotToColorConverter}}" />
                </Style>
            </DataGrid.RowStyle>-->
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseDoubleClick">
                    <i:InvokeCommandAction Command="{Binding ClientDetailsCommand}" CommandParameter="false" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </DataGrid>
    </Grid>
</UserControl>
